package com.fufan.demo.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fufan.demo.form.LoginActionForm;
import com.fufan.mvcframework.action.BaseAction;
import com.fufan.mvcframework.actionform.ActionForm;
import com.fufan.mvcframework.annocation.FufanAction;
import com.fufan.mvcframework.annocation.FufanMethod;

@FufanAction(path="login", actionForm="loginActionForm")
public class LoginAction extends BaseAction {

	@Override
	@FufanMethod("index")
	public String index(ActionForm actionForm, HttpServletRequest req, HttpServletResponse resp) {
		
		LoginActionForm laf = (LoginActionForm)actionForm;
		
		try {
			System.out.println(laf.toString());
			PrintWriter pWriter = resp.getWriter();
			pWriter.write("write json");
			pWriter.flush();
			pWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		return null;
	}
	
	@FufanMethod("add")
	public void add(ActionForm actionForm, HttpServletRequest req, HttpServletResponse resp) throws IOException {
		
		PrintWriter pWriter = resp.getWriter();
		pWriter.write("login add ...");
		pWriter.flush();
		pWriter.close();
	}
	
	@FufanMethod("delete")
	public void delete(){
		System.out.println("delete....");
	}
	
}
